<template>
  <div class="project_nav">

    <div class="project_nav_header">
      <el-dropdown>
        <span class="el-dropdown-link">
          {{ navName == 1 ? '当前项目' : (navName == 2 ? '最新项目' : '') }}
          <el-icon class="el-icon--right">
            <arrow-down />
          </el-icon>
        </span>
        <template #dropdown>
          <el-dropdown-menu>
            <el-dropdown-item @click="setNav(1)" divided :disabled="navName == 1">当前项目</el-dropdown-item>
            <el-dropdown-item @click="setNav(2)" divided :disabled="navName == 2">最新项目</el-dropdown-item>
          </el-dropdown-menu>
        </template>
      </el-dropdown>
    </div>
    <ProjectNavItem v-for="item in navItems" :key="item.id" :item="item" />


  </div>
</template>

<script setup lang="ts">
import { ArrowDown } from '@element-plus/icons-vue';
import ProjectNavItem from '@/components/projectNavItem/index.vue'
import { ref, inject, Ref } from 'vue';
import { IProject } from '@/types/project';


const navName = ref(1)

const navItems = inject<Ref<IProject[]>>("navItems")
function setNav(name: number) {
  if (navName.value == name) return;
  navName.value = name;
}

</script>

<style lang="scss" scoped>
.project_nav {
  width: 260px;
  background-color: white;
  border-radius: 20px;
  box-sizing: border-box;

  &_header {
    padding: 20px;
    border-bottom: 1px solid #f4f4f4;

    :deep(.el-dropdown) {
      display: flex;
      font-size: 18px;

    }

    .el-dropdown-link {
      color: #000;
      outline: none;
      display: flex;
      align-items: center;

    }
  }
}
</style>
